#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
typedef long long ll ;
typedef long double ld ;
typedef unsigned long long ull ;
typedef std::pair<int , int> pii ;
typedef std::pair<ll , ll> pll ;
typedef std::pair<ld , ld> pld ;
typedef std::vector<int> vi ;
typedef std::vector<char> vc ;
typedef std::vector<ll> vll ;
typedef std::vector<pii> vpi ;
typedef std::vector<pll> vpl ;
#define forn(i , a , b) for(int i = a ; i < b ; i ++)
#define sorn(i , a , b) for(int i = (a) - 1 ; i >= b ; i --)
#define rep(i , a) for(int i = 0 ; i < a ; i ++)
#define f first
#define s second
//#define endl "\n"
#define ins insert
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define all(tt) tt.begin() , tt.end()
#define read(x) scanf("%d", &x)
using namespace std ;
// int dx[4] = {1 , 0 , -1 , 0} ;
// int dy[4] = {0 , 1 , 0 , -1} ;
const int N = 2e5 + 10 ;
int a[N] , b[N] ;
int main ()
{
std::ios::sync_with_stdio(false) ;
std::cin.tie(0) ;
std::cout.tie(0) ;
int T ;
cin >> T ;
while (T --)
{
int n ;
cin >> n ;
string s ;
cin >> s ;
if(s == string(n, s[0]))
{
cout << "-1" << endl ;
continue ;
}
int ans = -1 ;
for(int i = 0 ; i < n - 1 ; i ++)
{
if(s[i] == 'R' && s[i + 1] == 'L')
{
ans = 0 ;
break ;
}
if (s[i] == 'L' && s[i + 1] == 'R')
{
ans = i + 1 ;
break ;
}
}
cout << ans << endl ;
}
return 0 ;
}
729D - Sea Battle | 788A - Functions again |
1245B - Restricted RPS | 1490D - Permutation Transformation |
1087B - Div Times Mod | 1213B - Bad Prices |
1726B - Mainak and Interesting Sequence | 1726D - Edge Split |
1726C - Jatayu's Balanced Bracket Sequence | 1726A - Mainak and Array |
1613C - Poisoned Dagger | 475B - Strongly Connected City |
652B - z-sort | 124B - Permutations |
1496C - Diamond Miner | 680B - Bear and Finding Criminals |
1036E - Covered Points | 1015D - Walking Between Houses |
155B - Combination | 1531A - Зингер | color |
1678A - Tokitsukaze and All Zero Sequence | 896A - Nephren gives a riddle |
761A - Dasha and Stairs | 1728B - Best Permutation |
1728A - Colored Balls Revisited | 276B - Little Girl and Game |
1181A - Chunga-Changa | 1728C - Digital Logarithm |
1728D - Letter Picking | 792B - Counting-out Rhyme |